<?php
/* @var $this HousingController */
/* @var $model Housing */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'housing-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
    'htmlOptions' => array(
        'enctype' => 'multipart/form-data')
));

Yii::app()->clientScript->registerCoreScript('jquery.ui');
//Yii::app()->clientScript->registerScript('today','
//$("#Housing_reserved_from").focus(function(){
//        $(this).val($.datepicker.formatDate("yy-mm-dd", new Date()));
//
//        });
//');

?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name_en'); ?>
		<?php echo $form->textField($model,'name_en',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name_en'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'name_ru'); ?>
		<?php echo $form->textField($model,'name_ru',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name_ru'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'name_uk'); ?>
		<?php echo $form->textField($model,'name_uk',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name_uk'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'name_ja'); ?>
		<?php echo $form->textField($model,'name_ja',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name_ja'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'about_en'); ?>
		<?php echo $form->textArea($model,'about_en',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'about_en'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'about_ru'); ?>
		<?php echo $form->textArea($model,'about_ru',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'about_ru'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'about_uk'); ?>
		<?php echo $form->textArea($model,'about_uk',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'about_uk'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'about_ja'); ?>
		<?php echo $form->textArea($model,'about_ja',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'about_ja'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'area'); ?>
		<?php echo $form->textField($model,'area'); ?>
		<?php echo $form->error($model,'area'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'location').
            CHtml::link('Manage locations',array('admin/DropDown/'),array('onclick'=>'this.target=\'_blank\';')); ?><br />
<!--		--><?php //echo $form->textField($model,'location',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->dropDownList($model,'location',$selector); ?>
		<?php echo $form->error($model,'location'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'type'); ?>
		<?php echo $form->radioButtonList($model,'type',array('Apartment'=>'Apartment', 'build'=>'Building Area',
            'Condo'=>'Condo', 'Cottage'=>'Cottage', 'Family House'=>'Family House', 'Single Home'=>'Single Home', 'Villa'=>'Villa'),array('separator'=>' ',
            'labelOptions'=>array('style'=>'display:inline'))); ?>
		<?php echo $form->error($model,'type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'beds'); ?>
		<?php echo $form->textField($model,'beds'); ?>
		<?php echo $form->error($model,'beds'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'bath'); ?>
		<?php echo $form->textField($model,'bath'); ?>
		<?php echo $form->error($model,'bath'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'price'); ?>
		<?php echo $form->textField($model,'price'); ?>
		<?php echo $form->error($model,'price'); ?>
	</div>

	<div style="display: block;border: 1px solid #000000;" class="row">
		<?php echo $form->labelEx($model,'amenities'); ?>
<!--        --><?php //echo $form->checkBoxList($model,'amenities',
//            array(
//                'condition' => 'Air conditioning',
//                'Balcony' => 'Balcony',
//                'Bedding' => 'Bedding',
//                'Cable' => 'Cable TV',
//                'Cleaning' => 'Cleaning after exit',
//                'Cofee' => 'Cofee pot',
//                'Computer' => 'Computer',
//                'Cot' => 'Cot',
//                'Dishwasher' => 'Dishwasher',
//                'Fan' => 'Fan',
//                'DVD' => 'DVD',
//                'Fridge' => 'Fridge',
//                'Grill' => 'Grill',
//                'Hairdryer' => 'Hairdryer',
//                'Heating' => 'Heating',
//                'Hifi' => 'Hi-fi',
//                'Internet' => 'Internet',
//                'Iron' => 'Iron',
//                'Juicer' => 'Juicer',
//                'Lift' => 'Lift',
//                'Microwave' => 'Microwave',
//                'Oven' => 'Oven',
//                'Parking' => 'Parking',
//                'Parquet' => 'Parquet',
//                'Radio' => 'Radio',
//                'Roof' => 'Roof terrace',
//                'Smoking' => 'Smoking allowed',
//                'Terrace' => 'Terrace',
//                'Toaster' => 'Toaster',
//                'Towelwes' => 'Towelwes',
//                'pool' => 'Use of pool',
//                'Video' => 'Video'),array('separator'=>' ',
//                'labelOptions'=>array('style'=>'display:inline; padding-right:40px; '))); ?>
        <?php echo $form->checkBoxList($model,'amenities',
            array(
                '0' => 'Air conditioning',
                '1' => 'Balcony',
                '2' => 'Bedding',
                '3' => 'Cable TV',
                '4' => 'Cleaning after exit',
                '5' => 'Cofee pot',
                '6' => 'Computer',
                '7' => 'Cot',
                '8' => 'Dishwasher',
                '9' => 'DVD',
                '10' => 'Fan',
                '11' => 'Fridge',
                '12' => 'Grill',
                '13' => 'Hairdryer',
                '14' => 'Heating',
                '15' => 'Hi-fi',
                '16' => 'Internet',
                '17' => 'Iron',
                '18' => 'Juicer',
                '19' => 'Lift',
                '20' => 'Microwave',
                '21' => 'Oven',
                '22' => 'Parking',
                '23' => 'Parquet',
                '24' => 'Radio',
                '25' => 'Roof terrace',
                '26' => 'Smoking allowed',
                '27' => 'Terrace',
                '28' => 'Toaster',
                '29' => 'Towelwes',
                '30' => 'Use of pool',
                '31' => 'Video'),array('separator'=>' ',
                'labelOptions'=>array('style'=>'display:inline; padding-right:40px; '))); ?>
<!--        --><?php //echo $form->textField($model,'amenities'); ?>
<!--        --><?php //print_r ($form);?>
<!--		--><?php //echo $form->error($model,'amenities'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'latitude'); ?>
		<?php echo $form->textField($model,'latitude'); ?>
		<?php echo $form->error($model,'latitude'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'longitude'); ?>
		<?php echo $form->textField($model,'longitude'); ?>
		<?php echo $form->error($model,'longitude'); ?>
	</div>

	<div style="display: none" class="row">
		<?php echo $form->labelEx($model,'create_date'); ?>
		<?php
        if($model->create_date=='0000-00-00'||$model->create_date==''||$model->create_date==null)
        echo $form->textField($model,'create_date',array('value'=>date('Y-m-d'))); ?>
		<?php echo $form->error($model,'create_date'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
<!--		--><?php //echo $form->textField($model,'status'); ?>
        <?php echo $form->radioButtonList($model,'status',array('0'=>'Sold', '1'=>'Sale', '2'=>'Rent'),array('separator'=>' ',
            'labelOptions'=>array('style'=>'display:inline'))); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'fetuared'); ?>
<!--		--><?php //echo $form->textField($model,'fetuared'); ?>
        <?php echo $form->radioButtonList($model,'fetuared',array('0'=>'No', '1'=>'Yes'),array('separator'=>' ',
            'labelOptions'=>array('style'=>'display:inline'))); ?>
		<?php echo $form->error($model,'fetuared'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'agent_id'); ?>
		<?php echo $form->textField($model,'agent_id'); ?>
		<?php echo $form->error($model,'agent_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'owner'); ?>
		<?php echo $form->textField($model,'owner',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'owner'); ?>
	</div>



	<div class="row">
		<?php echo $form->labelEx($model,'reserved_from'); ?>

<!--		--><?php //echo $form->timeField($model,'reserved_from'); ?>
<!--        --><?php //echo $form->dateField('date_name',date("Y-m-d"),array('id'=>'date_id')); ?>
<!--        --><?php //echo $form->textField($model,'reserved_from',array('size'=>60,'maxlength'=>255)); ?>
        <?php
        $this->widget('zii.widgets.jui.CJuiDatePicker', array(
            'model'=>$model,
            'attribute'=>'reserved_from',
            'options'=>array(
                'showAnim'=>'fold',
                'dateFormat'=>'yy-mm-dd',
            ),
            'htmlOptions'=>array(
                'style'=>'height:20px;'
            ),
        ))
        ?>
        <?php echo $form->error($model,'reserved_from'); ?>

	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'reserved_to'); ?>
<!--		--><?php //echo $form->textField($model,'reserved_to'); ?>
        <?php
        $this->widget('zii.widgets.jui.CJuiDatePicker', array(
            'model'=>$model,
            'attribute'=>'reserved_to',
            'options'=>array(
                'showAnim'=>'fold',
                'dateFormat'=>'yy-mm-dd',
            ),
            'htmlOptions'=>array(
                'style'=>'height:20px;'
            ),
        ))
        ?>
		<?php echo $form->error($model,'reserved_to'); ?>
	</div>

	<div style="display: none" class="row">
		<?php echo $form->labelEx($model,'votes'); ?>
		<?php echo $form->textField($model,'votes'); ?>
		<?php echo $form->error($model,'votes'); ?>
	</div>

	<div style="display: none" class="row">
		<?php echo $form->labelEx($model,'rate'); ?>
		<?php echo $form->hiddenField($model,'rate'); ?>
		<?php echo $form->error($model,'rate'); ?>
	</div>


<div class="row">
    <?php echo $form->labelEx($model, 'image'); ?>
    <?php echo $form->fileField($model, 'image'); ?>
    <?php echo $form->error($model, 'image'); ?>
    <?php
    if(!$model->isNewRecord) {
        echo '<br/>'.CHtml::image($model->getImageUrl(), $model->name_ja, array('style' => 'height: 200px'));
    }
    ?>
</div>

<div class="row">
    <?php
    echo $form->labelEx($model, 'images');
    $this->widget('CMultiFileUpload', array(
        'model' => $model,
        'attribute' => 'images',
        'accept' => 'jpg, gif, png, jpeg',
        'duplicate' => 'Этот файл уже выбран!',
        'denied' => 'Недопустимый тип файла',
    ));
    if ($model->housingImages) {
        $this->renderPartial('_imageGrid', array('model' => $model));
    }
    ?>
</div>

<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->